package com.itheima.day14.day14work5;

import java.util.ArrayList;
import java.util.Random;
import java.util.TreeSet;
import java.util.concurrent.Callable;

public class ChoujiangX  implements Callable<Integer> {

    int[] arr=new int[]{10,5,20,50,100,200,500,800,2,80,300,700};
    TreeSet<Integer>  ts=new TreeSet<Integer>();

    Random r=new Random();
    @Override
    public Integer call() throws Exception {
        int num=0;
        while (true){
            synchronized (this){

                  int i = r.nextInt(arr.length);
                    if (!ts.contains(arr[i])){
                        ts.add(arr[i]);
                        System.out.println(Thread.currentThread().getName() + "又产生了一个" + arr[i] + "元大奖");
                        num++;
                    }
                    if (ts.size()==12)
                        break;
                  }
          }
          return num;
    }
}
